home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
develop, the CD; issue 1
/
Apple_Develop_1989.bin
/
the Palette Manager
/
Palette.p
< prev
next >
Wrap
Text File
|
1989-09-20
|
1KB
|
71 lines
PROGRAM palette
USES
MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf, Traps;
FUNCTION MakeRedPalette: PaletteHandle;
VAR
i: LONGINT;
ph: PaletteHandle;
c: RGBColor;
BEGIN
ph := NewPalette(254+14,NIL,0,0);
(* should check for NIL result *)
c.green := 0;
c.blue := 0;
(* Make fourteen reds that are inhibited on all *)
(* screens except four-bit color *)
FOR i:=0 TO 13
DO
BEGIN
(* range red component from 1/14 to 14/14 *)
(* i is a longint, and so can safely be multiplied by 65535 *)
c.red := (i+1)*65535 DIV 14;
SetEntryColor(ph,i,c);
SetEntryUsage(ph,i,pmTolerant+pmInhibitC2+
pmInhibitG2+pmInhibitG4+
pmInhibitC8+pmInhibitG8,4000);
END;
(* Make 254 reds that are inhibited on all *)
(* screens except eight-bit color *)
FOR i:=0 TO 254
DO
BEGIN
(* range red component from 1/14 to 14/14 *)
(* i is a longint, and so can safely be multiplied by 65535 *)
c.red := (i+1)*65535 DIV 254;
SetEntryColor(ph,14+i,c);
SetEntryUsage(ph,14+i,pmTolerant+pmInhibitC2+
pmInhibitG2+pmInhibitG4+
pmInhibitC4+pmInhibitG8,0);
END;
MakeRedPalette := ph;
END;
myPP: PixPatHandle;
myCT: CTabHandle;
myPP := GetPixPat(16); (* Gets the system color desktop pattern *)
myCT := myPP^^.patMap^^.pmTable
FOR j := 0 TO myCT^^.ctSize
DO
myCT^^.ctTable[j].value := j;
myCT^^.ctFlags := myCT^^.ctFlags+$4000; (* .ctFlags aka .transinde *)
(* would be bad if bit 14 were already set *)